package com.jzg.jcptadmin.adpter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jzg.jcptadmin.R;
import com.jzg.jcptadmin.app.AppContext;
import com.jzg.jcptadmin.data.vo.CarManagerData;
import com.jzg.template.refreshrecycleview.RefreshBaseAdapter;
import com.jzg.template.refreshrecycleview.RefreshEntity;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by jzg on 2016/1/8.
 */
public class CarManagerAdapter extends RefreshBaseAdapter {


    private Context mContext;
    private List<CarManagerData.CarlistEntity> mDatas;
    private final AppContext appContext;

    public CarManagerAdapter(Context mContext, List<CarManagerData.CarlistEntity> mDatas) {
        super(mContext, mDatas);
        this.mContext = mContext;
        this.mDatas = mDatas;

        appContext = (AppContext) mContext.getApplicationContext();
    }

    public void upData(List<CarManagerData.CarlistEntity> mDatas) {
        this.mDatas = mDatas;
    }

    @Override
    public RecyclerView.ViewHolder getHolderView(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.car_manageradapter_item, null));
    }

    @Override
    public void onBindView(RecyclerView.ViewHolder holder, int position, RefreshEntity entity) {
        MyViewHolder myViewHolder = (MyViewHolder) holder;
        CarManagerData.CarlistEntity entity1 = (CarManagerData.CarlistEntity) entity;
        myViewHolder.itemBuyCarName.setText(entity1.getFullName());
        myViewHolder.itemBuyCarSeeTimes.setText(entity1.getRegDateString());
         myViewHolder.itemBuyCarMileage.setText(entity1.getMileageString()+"");
        myViewHolder.itemBuyCarArea.setText(entity1.getCityName());
      ImageLoader.getInstance().displayImage(entity1.getPicPath(), myViewHolder.itemBuyCarIcon, appContext.options);
    }

    class MyViewHolder extends RecyclerView.ViewHolder {


        /* @Bind(R.id.item_buy_car_icon)
         ImageView itemBuyCarIcon;
         @Bind(R.id.item_buy_car_name)
         TextView itemBuyCarName;
         @Bind(R.id.item_buy_car_see_times)
         TextView itemBuyCarSeeTimes;
         @Bind(R.id.item_buy_car_mileage)
         TextView itemBuyCarMileage;
         @Bind(R.id.item_buy_car_area)
         TextView itemBuyCarArea;
         @Bind(R.id.item_buy_car_rightcenter)
         LinearLayout itemBuyCarRightcenter;
         @Bind(R.id.item_buy_car_price)
         TextView itemBuyCarPrice;
         @Bind(R.id.relativeLayout)
         RelativeLayout relativeLayout;
         @Bind(R.id.item_buy_car_jiage)
         TextView itemBuyCarJiage;*/
        @Bind(R.id.item_buy_car_icon)
        ImageView itemBuyCarIcon;
        @Bind(R.id.item_buy_car_name)
        TextView itemBuyCarName;
        @Bind(R.id.item_buy_car_see_times)
        TextView itemBuyCarSeeTimes;
        @Bind(R.id.item_buy_car_mileage)
        TextView itemBuyCarMileage;
        @Bind(R.id.item_buy_car_area)
        TextView itemBuyCarArea;
        @Bind(R.id.item_buy_car_rightcenter)
        LinearLayout itemBuyCarRightcenter;
        @Bind(R.id.item_buy_car_price)
        TextView itemBuyCarPrice;
        @Bind(R.id.item_buy_car_jiage)
        TextView itemBuyCarJiage;
        @Bind(R.id.tv_zaiku)
        TextView tv_zaiku;
        @Bind(R.id.relativeLayout)
        RelativeLayout relativeLayout;
        public MyViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
